//
//  PersonalInfoTableVC.m
//  PersonalOC
//
//  Created by 韩琴 on 2018/8/27.
//  Copyright © 2018年 韩琴. All rights reserved.
//

#import "PersonalInfoTableVC.h"

@interface PersonalInfoTableVC ()
@property (weak, nonatomic) IBOutlet UIImageView *avatarImageView;
@property (weak, nonatomic) IBOutlet UILabel *sexLabel;
@property (weak, nonatomic) IBOutlet UILabel *brithdayLable;

@end

@implementation PersonalInfoTableVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"个人资料";
    if ([_userModel.headPicUrl ly_isValidUrl]) {
        [LYTools sd_setImageWithimageView:self.avatarImageView withImageUrl:_userModel.headPicUrl withPlaceholderImage:LY_default_avavtar withCompleted:nil];
    } else {
        self.avatarImageView.image = LY_IMAGE_NAMED(_userModel.headPicUrl);
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
//Mark -tableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView deselectRowAtIndexPath:indexPath animated:true];
    if (indexPath == [NSIndexPath indexPathForItem:0 inSection:0]) {
        
        [LYMedia openImageWithMaxImgNumber:1 WithCuVc:[LYTools getCurrentVC] withAllowsEditing:true allowPickingVideo:NO withOverBlock:^(NSArray *dataArr) {
            NSLog(@"%@",dataArr);
            self.avatarImageView.image = dataArr[0];
        }];
    } else if (indexPath == [NSIndexPath indexPathForItem:0 inSection:1]) {
        [LYView showPikerViewWithTitle:@"请选择" withInVc:self WithType:YLDataConfigTypeGender selectedData:nil callBack:^(NSArray *selectedData) {
            NSLog(@"%@",selectedData);
            if (selectedData.count>0) {
                self.sexLabel.text = ((YLAwesomeData*)selectedData[0]).name;
                self.sexLabel.textColor = UIColor.darkTextColor;
            }
        }];
    } else if (indexPath == [NSIndexPath indexPathForItem:1 inSection:1]) {
        [LYView showTimePikerViewWithTitle:@"请选择出生日期" withInVc:self callBack:^(NSDate *date) {
            NSLog(@"%@",date);
            NSString *timestr = [LYTools NSDateToWork:date wityType:timeStampTypeD];
            self.brithdayLable.text = timestr;
            self.brithdayLable.textColor = UIColor.darkTextColor;
        }];
    }
}
@end
